home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 982 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.2 KB  |  43 lines

  1. Path: news.edge.net!news
  2. From: cmclaur@edge.net (Chris McLaurin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Please help, file read and write problem.
  5. Date: Mon, 08 Jan 1996 21:11:12 GMT
  6. Organization: The Edge
  7. Message-ID: <4crq6o$30l@excalibur.edge.net>
  8. NNTP-Posting-Host: ip152.nash.edge.net
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. struct stub {
  12.     int delete_flag;        //enum DeleteFlag ACTIVE/DELETED
  13.     int recordnum;          //a sequential number in the file
  14. } rec;
  15.  
  16. dfile is opened and correctly positioned.
  17.  
  18. when rec.recordnum = 1 to 10, the following works fine.
  19.             dfile.write((char *) &rec, sizeof rec) ;
  20. ---  and ---
  21.             dfile.read((char *) &rec, sizeof rec);
  22.  
  23. ------------------------------------------------------------------------------------------
  24.  
  25. if rec.recordnum = 11 then a hex dump of
  26.         dfile.write((char *) &rec, sizeof rec) ;
  27. looks correct, but:
  28.             dfile.read((char *) &rec, sizeof rec);
  29.             cout << rec.recordnum;
  30. consistantly returns:
  31.              2895
  32.  
  33. any time rec.recordnum >= 11 the numbers read into rec.recordnumber
  34. are incorrect.
  35.  
  36. Please help ...
  37.  
  38. Chris McLaurin
  39. Open Systems Integrators, Inc.
  40. http://edge.edge.net/~cmclaur | PGP available via finger or URL
  41. "Success is in the effort." -clm
  42.  
  43.